\name{SimpleSlopes}
\alias{SimpleSlopes}
\title{Calculate and Test Simple Slopes}
\description{This function calculates simple slopes and tests their significance.}
\usage{
SimpleSlopes(object, x, intvar, intval, values)
}
\arguments{
  \item{object}{A (linear) model object.}
  \item{x}{A character string indicating which variable is the continuous interaction variable.}
  \item{intvar}{A character string indicating which variable is the interaction variable to be tested at a few values.}
  \item{intval}{The values to use for \code{intval}.}
  \item{values}{Something left over from the fact that I abstracted this from a larger function and have not had time to properly make it standalone.}
}
\details{Coming soon.}
\value{
  \item{coefficients}{A matrix of simple slope estimates and their significance tests.}
  \item{B}{The model coefficients}
  \item{Sigma}{The model variance covariance matrix}
  \item{model}{The model used to test the simple slopes.  A matrix.}
  \item{df.residual}{The residual degrees of freedom (used to calculate p-values)}
}
\references{Aiken & West 1991}
\author{Joshua Wiley, \url{http://joshuawiley.com/}}
\note{More should be coming soon and this will improve.}
\seealso{\code{\link{IntData}} the function I abstracted this from.}
\examples{
##---- Should be DIRECTLY executable !! ----
##-- ==>  Define data, use random,
##--	or do  help(data=index)  for the standard data sets.

## The function is currently defined as
function (object, x, intvar, intval, values)
{
    values[, x] <- 1
    tt <- terms(object)
    Terms <- delete.response(tt)
    intval <- list(unique(intval))
    names(intval) <- intvar
    tmp <- expand.grid(intval)
    slopedat <- do.call(rbind, rep(list(values), nrow(tmp)))
    slopedat[, colnames(tmp)] <- tmp
    MF <- model.frame(Terms, slopedat, na.action = "na.omit",
        xlev = object$xlevels)
    if (!is.null(cl <- attr(Terms, "dataClasses")))
        .checkMFClasses(cl, MF)
    X <- model.matrix(Terms, MF, contrasts.arg = object$contrasts)
    L <- attr(Terms, "factors")
    mode(L) <- "logical"
    zero.index <- !attr(X, "assign") \%in\% which(L[x, ])
    X[, zero.index] <- 0
    B <- matrix(coef(object))
    Sb <- vcov(object)
    slopes <- as.vector(X \%*\% B)
    SE <- sqrt(diag(X \%*\% Sb \%*\% t(X)))
    df <- object$df.residual
    tval <- slopes/SE
    pval <- 2 * pt(q = abs(tval), df = df, lower.tail = FALSE)
    coeff <- data.frame(slopes, SE, tval, pval)
    colnames(coeff) <- c("Simple Slope", "Std. Error", "t value",
        "Pr(>|t|)")
    output <- list(coefficients = coeff, B = B, Sigma = Sb, model = X,
        df.residual = df)
    return(output)
  }
}
\keyword{htest}
